<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>雁过留声</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="雁过留声">
<meta property="og:url" content="http://yanglf007.gitee.io/blog/page/4/index.html">
<meta property="og:site_name" content="雁过留声">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="yanglf007">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/blog/atom.xml" title="雁过留声" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/blog/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/blog/" id="logo">雁过留声</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/blog/">Home</a>
        
          <a class="main-nav-link" href="/blog/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/blog/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yanglf007.gitee.io/blog"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-arthas知识" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/05/31/arthas%E7%9F%A5%E8%AF%86/" class="article-date">
  <time datetime="2020-05-30T17:49:49.739Z" itemprop="datePublished">2020-05-31</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/05/31/arthas%E7%9F%A5%E8%AF%86/">arthas知识</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>#热更新类</p>
<p>#下载源码</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jad --source-only com.example.demo.arthas.user.UserController &gt; /tmp/UserController.java</span><br></pre></td></tr></table></figure>


<h1 id="模糊搜索类"><a href="#模糊搜索类" class="headerlink" title="模糊搜索类"></a>模糊搜索类</h1><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sc *HelloService*</span><br></pre></td></tr></table></figure>
<h1 id="打印类详细信息-f-打印成员变量信息"><a href="#打印类详细信息-f-打印成员变量信息" class="headerlink" title="打印类详细信息 -f 打印成员变量信息"></a>打印类详细信息 -f 打印成员变量信息</h1><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sc -d com.yanglf.mytask.controller.HelloController</span><br><span class="line">sc -d -f com.yanglf.mytask.controller.HelloController</span><br></pre></td></tr></table></figure>

<p>#编译修改后的文件</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mc /tmp/UserController.java -d /tmp</span><br></pre></td></tr></table></figure>
<p>#重新加载类</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">redefine /tmp/com/example/demo/arthas/user/UserController.class</span><br></pre></td></tr></table></figure>

<p>#查超时问题</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">trace com.cainiao.cam.business.web.excel.ExcelController download  '#cost &gt; 10'</span><br></pre></td></tr></table></figure>

<p>#热更新类</p>
<p>#下载源码</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jad --source-only com.example.demo.arthas.user.UserController &gt; /tmp/UserController.java</span><br></pre></td></tr></table></figure>
<p>#编译修改后的文件</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mc /tmp/UserController.java -d /tmp</span><br></pre></td></tr></table></figure>
<p>#重新加载类</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">redefine /tmp/com/example/demo/arthas/user/UserController.class</span><br></pre></td></tr></table></figure>

<p>#查超时问题</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">trace com.cainiao.cam.business.web.excel.ExcelController download  '#cost &gt; 10'</span><br></pre></td></tr></table></figure>

<h1 id="查看入参出参"><a href="#查看入参出参" class="headerlink" title="查看入参出参"></a>查看入参出参</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">watch com.yanglf.hello.controller.HelloController say &quot;&#123;params,returnObj&#125;&quot; -x 2</span><br></pre></td></tr></table></figure>
<p>monitor -c 5 com.sz.Test test<br>watch com.sz.Test test “{params,returnObj}” “params[1]==5” -x 3<br>watch com.sz.Test test “{params[0],throwExp}” -e -x 2</p>
<h1 id="查看入参出参-1"><a href="#查看入参出参-1" class="headerlink" title="查看入参出参"></a>查看入参出参</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">watch com.yanglf.hello.controller.HelloController say &quot;&#123;params,returnObj&#125;&quot; -x 2</span><br></pre></td></tr></table></figure>

<p>tt -t 进行现场记录</p>
<p>tt -i index 回放</p>
<p>tt -i index -p 重新调用一次 （–replay-times,–replay-interval）</p>
<h1 id="打印方法调用堆栈"><a href="#打印方法调用堆栈" class="headerlink" title="打印方法调用堆栈"></a>打印方法调用堆栈</h1><p>stack com.yanglf.mytask.controller.HelloController#sayHello2</p>
<h2 id="ognl表达式过滤"><a href="#ognl表达式过滤" class="headerlink" title="ognl表达式过滤"></a>ognl表达式过滤</h2><p>stack com.yanglf.mytask.controller.HelloController sayHello2 ‘params[0].equals(“yanglf”)’</p>
<h2 id="根据日志级别"><a href="#根据日志级别" class="headerlink" title="根据日志级别"></a>根据日志级别</h2><p> logger –name ROOT –level debug<br> 或者 logger -c 类加载器hashcode –name ROOT –level debug<br> 类加载器hashcode 可以通过 sc -d 获取<br>ognl ‘@org.springframework.util.StringUtils.replace(“yanglf007”,”007”)’</p>
<p>ognl 调用静态方法</p>
<p>ognl -c 31cefde0 ‘@org.springframework.util.StringUtils@delete(“yanglf007”,”007”)’</p>
<p>sm 查看类方法信息<br>sm -d <em>HelloController</em></p>
<p>dump 类名<br>导出类class文件</p>
<p>heapdump 导出 堆内存</p>
<p>tt 获取任意bean,并且执行方法<br>tt -t org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter invokeHandlerMethod<br>tt -i 1001 -w ‘target.getApplicationContext().getBean(“helloController”).sayHello()’</p>
<p>tt -l 查看tt内容<br>tt 过滤<br>tt -s ‘method.name==”sayHello2”‘</p>
<p>解决方法重载</p>
<p>tt -t *Test print params.length==1</p>
<p>通过制定参数个数的形式解决不同的方法签名，如果参数个数一样，你还可以这样写</p>
<p>tt -t *Test print ‘params[1] instanceof Integer’</p>
<p>解决指定参数</p>
<p>tt -t *Test print params[0].mobile==”13989838402”</p>
<p>构成条件表达式的 Advice 对象</p>
<p>前边看到了很多条件表达式中，都使用了 params[0]，有关这个变量的介绍，请参考表达式核心变量</p>
<p>watch com.chengjf.snippet.spring.mvc.service.HelloService sayHello “{target.clear()}” -x 10 -n 1</p>
<h2 id="tt调用方法-复杂对象时可以转换成字符串处理"><a href="#tt调用方法-复杂对象时可以转换成字符串处理" class="headerlink" title="tt调用方法,复杂对象时可以转换成字符串处理"></a>tt调用方法,复杂对象时可以转换成字符串处理</h2><p>tt -i 1000 -w ‘target.getApplicationContext().getBean(“weChatServiceImpl”).sendMessage(“{&quot;content&quot;:&quot;content&quot;,&quot;recipient&quot;:&quot;recipient&quot;,&quot;subject&quot;:&quot;subject6&quot;}”)’</p>
<h2 id="获取静态变量属性值"><a href="#获取静态变量属性值" class="headerlink" title="获取静态变量属性值"></a>获取静态变量属性值</h2><p>getstatic com.kuaidizs.general.common.nacos.NacosConfigConstant  SWITCH_LIMIT_STATUS</p>
<h2 id="ognl-直接-调用静态方法"><a href="#ognl-直接-调用静态方法" class="headerlink" title="ognl 直接 调用静态方法"></a>ognl 直接 调用静态方法</h2><p>ognl -c 45934fa0  ‘@com.kuaidizs.general.api.common.MallCommonConfig@isProd()’</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/05/31/arthas%E7%9F%A5%E8%AF%86/" data-id="ckgtnonlv0001m8ulerj9625e" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-redis知识" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/05/30/redis%E7%9F%A5%E8%AF%86/" class="article-date">
  <time datetime="2020-05-30T13:59:09.128Z" itemprop="datePublished">2020-05-30</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/05/30/redis%E7%9F%A5%E8%AF%86/">redis知识</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>#docker运行redis</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d  --restart=always -v /root/file/redis.conf:/home/redis.conf -p 6379:6379 --name my_redis d4f259423416 redis-server /home/redis.conf</span><br></pre></td></tr></table></figure>

<p>#设置密码</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">修改redis.conf requirepass tenny     &#x2F;&#x2F;注意，行前不能有空格</span><br></pre></td></tr></table></figure>
<ol>
<li>哨兵模式</li>
</ol>
<p>哨兵模式是一种特殊的模式，首先Redis提供了哨兵的命令，哨兵是一个独立的进程，作为进程，它会独立运行。其原理是哨兵通过发送命令，<br>等待Redis服务器响应，从而监控运行的多个Redis实例</p>
<p>用文字描述一下故障切换（failover）的过程。假设主服务器宕机，哨兵1先检测到这个结果，<br>系统并不会马上进行failover过程，仅仅是哨兵1主观的认为主服务器不可用，这个现象成为主观下线。<br>当后面的哨兵也检测到主服务器不可用，并且数量达到一定值时，那么哨兵之间就会进行一次投票，<br>投票的结果由一个哨兵发起，进行failover操作。切换成功后，就会通过发布订阅模式，让各个哨兵把自己监控的从服务器实现切换主机，<br>这个过程称为客观下线。这样对于客户端而言，一切都是透明的</p>
<p>2,Redis 常见性能问题和解决方案？<br>主库避免开启数据备份，从库可以开启，每秒同步一次<br>主库和重库避免跨机房，在同一局域网内</p>
<ol start="3">
<li>redis主从复制<br>全量复制<br>一. 从服务器通过slaveof 找到主服务器的ip和端口,链接上主服务器<br>二. 从服务器向主服务器发送psync 命令,要求同步数据<br>三. 主服务器收到命令,使用bgsave,异步将内存中的数据写入到磁盘中,同时开启缓存,之后的写命令进入缓存区<br>四. 主服务器向从服务器发送rdb文件,从服务器接受文件,解析并载入内存<br>五. 发送缓冲期数据,从服务器刷新数据</li>
</ol>
<p>部分复制<br>如果因为网络抖动,主从服务器断开链接<br>主服务器 写命令进入复制缓存区<br>从服务器执行sync命令,带上run_id 和 off_set<br>主服务器查看off_set是否在缓存区范围之内,如果在,主服务器就会发送continue命令,从偏移量开始同步数据</p>
<p>offset 在主服务表示已经发送的位置<br>        在从服务器表示已经接受的位置,两个直接就是从服务器需要同步的数据</p>
<p>4.redis原理</p>
<ol start="5">
<li>redis选举</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/05/30/redis%E7%9F%A5%E8%AF%86/" data-id="ckgtnonn1000hm8ulh73f1o6d" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-git知识" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/05/08/git%E7%9F%A5%E8%AF%86/" class="article-date">
  <time datetime="2020-05-07T17:26:50.643Z" itemprop="datePublished">2020-05-08</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/05/08/git%E7%9F%A5%E8%AF%86/">git知识</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="gitignore配置后不生效"><a href="#gitignore配置后不生效" class="headerlink" title="gitignore配置后不生效"></a>gitignore配置后不生效</h3><p>解决方法: git清除本地缓存（改变成未track状态），然后再提交:</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">git rm -r --cached .</span><br><span class="line">git add .</span><br><span class="line">git commit -m 'update .gitignore'</span><br><span class="line">git push -u origin master</span><br><span class="line">git branch --contains 9cd1cf0270d38a426300c38a901f8d79dfe7f10b</span><br></pre></td></tr></table></figure>

<p>回到过去某个提交</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git reset --hard 2afd5d4dd9bccac549d38ebc41e19ee1b4fff196</span><br><span class="line"></span><br><span class="line">git push -f -u origin master</span><br></pre></td></tr></table></figure>

<p>中文乱码问题</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">进入windoes的cmd 然后分别输入以下五行</span><br><span class="line">git config --global core.quotepath false</span><br><span class="line">git config --global gui.encoding utf-8</span><br><span class="line">git config --global i18n.commit.encoding utf-8</span><br><span class="line">git config --global i18n.logoutputencoding utf-8</span><br><span class="line">set LESSCHARSET=utf-8</span><br></pre></td></tr></table></figure>


<p>windows git reset –hard HEAD^后显示more?的解决方案</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">改为 git reset --hard "HEAD^"</span><br></pre></td></tr></table></figure>

<p>找回git add过的文件，但是被git reset 重置过的</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git fsck --lost-found</span><br><span class="line">在 .git\lost-found\other 目录下</span><br></pre></td></tr></table></figure>

<p>把其他分支上的提交记录复制到当前位置</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git cherry-pick fba4536</span><br></pre></td></tr></table></figure>

<p>如果代码已经提交，被get reset –hard 重置<br>可以通过下面命令找回</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git reset --hard "cdf6196"</span><br></pre></td></tr></table></figure>

<p>git reset –hard 与 git reset (–soft) 区别</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">--hard 会清空工作区，回到上一个提交版本 </span><br><span class="line">--soft 会保留上传提交的内容到工作区，可以进行修改后重新提交</span><br></pre></td></tr></table></figure>


<p>git commit  提交后修改信息或者合并两次提交</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git commit --amend</span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/05/08/git%E7%9F%A5%E8%AF%86/" data-id="ckgtnonms0006m8ulfrftakgx" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-markdown语法" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/04/20/markdown%E8%AF%AD%E6%B3%95/" class="article-date">
  <time datetime="2020-04-19T16:16:51.111Z" itemprop="datePublished">2020-04-20</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/04/20/markdown%E8%AF%AD%E6%B3%95/">markdown语法</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="无序列表"><a href="#无序列表" class="headerlink" title="无序列表 - + *"></a>无序列表 - + *</h3><p>eg:</p>
<ul>
<li>娟娟</li>
<li>佳佳</li>
<li>妮妮</li>
</ul>
<h3 id="有序列表-1"><a href="#有序列表-1" class="headerlink" title="有序列表 1."></a>有序列表 1.</h3><ol>
<li>时间</li>
<li>地点</li>
<li>人物</li>
</ol>
<h3 id="字体加粗"><a href="#字体加粗" class="headerlink" title="字体加粗"></a>字体加粗</h3><p><strong>加粗</strong></p>
<p>###创建一个表格</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">| 一个普通标题 | 一个普通标题 | 一个普通标题 |</span><br><span class="line">| ------ | ------ | ------ |</span><br><span class="line">| 短文本 | 中等文本 | 稍微长一点的文本 |</span><br><span class="line">| 稍微长一点的文本 | 短文本 | 中等文本 |</span><br></pre></td></tr></table></figure>


<table>
<thead>
<tr>
<th>一个普通标题</th>
<th>一个普通标题</th>
<th>一个普通标题</th>
</tr>
</thead>
<tbody><tr>
<td>短文本</td>
<td>中等文本</td>
<td>稍微长一点的文本</td>
</tr>
<tr>
<td>稍微长一点的文本</td>
<td>短文本</td>
<td>中等文本</td>
</tr>
</tbody></table>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/04/20/markdown%E8%AF%AD%E6%B3%95/" data-id="ckgtnonmz000fm8ul4bd006wh" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-heox知识" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/04/19/heox%E7%9F%A5%E8%AF%86/" class="article-date">
  <time datetime="2020-04-19T12:00:20.362Z" itemprop="datePublished">2020-04-19</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/04/19/heox%E7%9F%A5%E8%AF%86/">heox知识</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>##打包发布<br>hexo clean &amp;&amp; hexo g &amp;&amp; hexo d</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/04/19/heox%E7%9F%A5%E8%AF%86/" data-id="ckgtnonmt0007m8ul3tja2k66" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-mysql知识" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/04/19/mysql%E7%9F%A5%E8%AF%86/" class="article-date">
  <time datetime="2020-04-19T12:00:05.942Z" itemprop="datePublished">2020-04-19</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/04/19/mysql%E7%9F%A5%E8%AF%86/">mysql知识</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>###备份mysql数据库</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysqldump -uroot -h127.0.0.1 -P3307 -proot -A &gt;/root/file/backsql/databases_`date +%Y%m%d`.sql;</span><br></pre></td></tr></table></figure>

<p>#docker 启动mysql</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -p 3307:3306 --restart=always --name my-mysql -e MYSQL_ROOT_PASSWORD=root1 -d a559f1d39b0f</span><br></pre></td></tr></table></figure>

<ol>
<li>mysql什么情况下不走索引</li>
</ol>
<p>索引列参与计算<br>索引使用函数<br>索引使用了like %在前<br>字符串与数字之间比较<br>用or或者&lt;&gt;</p>
<ol start="2">
<li>mysql事物隔离级别怎么实现</li>
</ol>
<p>事物隔离级别分为四种<br>读未提交(不加锁)<br>读已提交<br>可重复读<br>串行化<br>可重复读有幻读的问题，幻读就是事物a更新了一批数据，未提交事物，事物b又插入了新数据，先提交了事物，看起来像事物a没有更新到全部数据<br>可重复读是指，事务不会读到其他事务对已有数据的修改，及时其他事务已提交，也就是说，事务开始时读到的已有数据是什么，在事务提交前的任意时刻，这些数据的值都是一样的。但是，对于其他事务新插入的数据是可以读到的，这也就引发了幻读问题。<br>串行化读 加共享锁，可读不可写，等前一个事物执行完成<br>通过mvcc（多版本并发控制实现）<br>开启事物<br>每行数据有一个字段是 事物ID， 查询数据的时候会查询当前事物下的版本数据，可以解决不可重复的问题，<br>规定，事物ID在我之前并且已经提交的，才能查到，事物id在我之后，或者未提交事物的都不能看的</p>
<ol start="3">
<li>explain 执行计划解读</li>
</ol>
<p>select_type 查询的类型,主要用于区别普通查询,联合查询,子查询等复杂查询<br>    simple: 简单的select查询,查询中不包含子查询或union查询<br>    primary: 查询中若包含任何复杂的子部分,最外层查询则被标记为primary<br>    subquery 在select 或where 列表中包含了子查询<br>    derived 在from列表中包含的子查询被标记为derived,mysql会递归这些子查询,把结果放在临时表里<br>    union 做第二个select出现在union之后,则被标记为union,若union包含在from子句的子查询中,外层select将被标记为derived<br>    union result 从union表获取结果的select</p>
<p>type<br>　　查询类型从最好到最差依次是:system&gt;const&gt;eq_ref&gt;ref&gt;range&gt;index&gt;All,一般情况下,得至少保证达到range级别,最好能达到ref<br>    system:表只有一行记录,这是const类型的特例,平时不会出现<br>    const:表示通过索引一次就找到了,const即常量,它用于比较primary key或unique索引,因为只匹配一行数据,所以效率很快,如将主键置于where条件中,mysql就能将该查询转换为一个常量<br>    eq_ref:唯一性索引扫描,对于每个索引键,表中只有一条记录与之匹配,常见于主键或唯一索引扫描<br>    ref:非唯一性索引扫描,返回匹配某个单独值的行,它可能会找到多个符合条件的行,所以他应该属于查找和扫描的混合体<br>    range:只检索给定范围的行,使用一个索引来选择行,如where语句中出现了between,&lt;,&gt;,in等查询,这种范围扫描索引比全表扫描要好，因为它只需要开始于索引的某一点，而结束于另一点，不用扫描全部索引。<br>    index:index类型只遍历索引树,这通常比All快,因为索引文件通常比数据文件小,index是从索引中读取,all从硬盘中读取<br>    all:全表扫描,是最差的一种查询类型</p>
<p>Extra<br>    Using filesort:说明mysql会对数据使用一个外部的索引排序,而不是按照表内的索引顺序进行读取,mysql中无法利用索引完成的排序操作称为”文件排序”<br>    Using temporary :使用了临时表保存中间结果,mysql在对查询结果排序时使用临时表,常见于order by和分组查询group by<br>    Using index:表示相应的select操作中使用了覆盖索引（Covering Index），避免访问了表的数据行，效率不错。如果同时出现using where，表明索引被用来执行索引键值的查找；如果没有同时出现using where，表明索引用来读取数据而非执行查找动作。 其中的覆盖索引含义是所查询的列是和建立的索引字段和个数是一一对应的<br>    Using where:表明使用了where过滤<br>    Using join buffer:表明使用了连接缓存,如在查询的时候会有多次join,则可能会产生临时表<br>    impossible where:表示where子句的值总是false,不能用来获取任何元祖。如下例：</p>
<p>重点：<br>　　type：访问类型，查看SQL到底是以何种类型访问数据的。<br>　　key：使用的索引，MySQL用了哪个索引，有时候MySQL用的索引不是最好的，需要force index()。<br>　　rows：最大扫描的列数。<br>　　extra：重要的额外信息，特别注意损耗性能的两个情况，using filesort和using temporary。</p>
<p>分库分表带来的问题<br>1,查询必须带分库分表键<br>2,事务问题<br>可以通过2pc和tcc解决<br>2pc有个协调者的概念,协调者发起是否提交事务,如果都返回ok,则开始提交,提交事务失败,或者等待超时,则取消事务</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/04/19/mysql%E7%9F%A5%E8%AF%86/" data-id="ckgtnonn2000im8ulchqlbecb" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-linux知识" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/04/19/linux%E7%9F%A5%E8%AF%86/" class="article-date">
  <time datetime="2020-04-19T11:59:51.499Z" itemprop="datePublished">2020-04-19</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/04/19/linux%E7%9F%A5%E8%AF%86/">linux知识</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="linux定时任务"><a href="#linux定时任务" class="headerlink" title="linux定时任务"></a>linux定时任务</h3><p>crontab -e 编辑定时任务<br>crontab时间设置<br>五个数字代表 分 时 日 月 周</p>
<ul>
<li>*代表任意</li>
<li>-代表从多少到多少</li>
<li>,代表 几和几</li>
<li>/代表每隔多久</li>
</ul>
<h3 id="当前日期"><a href="#当前日期" class="headerlink" title="当前日期"></a>当前日期</h3><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo `date +%Y%m%d`</span><br></pre></td></tr></table></figure>

<h3 id="ssh内网穿透"><a href="#ssh内网穿透" class="headerlink" title="ssh内网穿透"></a>ssh内网穿透</h3><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh -CqTfnN -R 132.132.14.175:6379:localhost:6379 root@132.232.14.175</span><br></pre></td></tr></table></figure>

<p>holer 内网穿透</p>
<p>内网传统方案<br><a href="https://github.com/wisdom-projects/holer-server" target="_blank" rel="noopener">https://github.com/wisdom-projects/holer-server</a></p>
<p>启动 redis 客户端 npm run electron</p>
<h3 id="sed-命令"><a href="#sed-命令" class="headerlink" title="sed 命令"></a>sed 命令</h3><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">在文本末尾添加字符串</span><br><span class="line">sed -i '$a yanglf'</span><br><span class="line"></span><br><span class="line">删除前行</span><br><span class="line">sed -i '1,3d' /etc/apt/sources.list</span><br></pre></td></tr></table></figure>


<p>docker中修改apt-get镜像源</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">修改镜像源地址</span><br><span class="line">sed -i '$a deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse' /etc/apt/sources.list</span><br><span class="line">sed -i '$a deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse' /etc/apt/sources.list</span><br><span class="line">sed -i '$a deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse' /etc/apt/sources.list</span><br><span class="line">sed -i '$a deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse' /etc/apt/sources.list</span><br><span class="line"></span><br><span class="line">文本替换</span><br><span class="line">sed -i '1s/old/new/g' myid</span><br></pre></td></tr></table></figure>


<p>#YUM在线安装</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd -y</span><br></pre></td></tr></table></figure>
<p>#系统扫描</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">clamscan -r /etc/ &gt;/tmp/etc.log</span><br></pre></td></tr></table></figure>

<p>grep  Infected /tmp/all.log<br>#查看被感染文件数量<br>grep -i found   /tmp/all.log<br>#查看被感染的文件</p>
<p>vmstat命令</p>
<p><a href="https://www.cnblogs.com/ftl1012/p/vmstat.html" target="_blank" rel="noopener">https://www.cnblogs.com/ftl1012/p/vmstat.html</a></p>
<p>查看文件有多少行<br>wc -l </p>
<p>文本编码转换<br> iconv -f 原始编码 -t 目标编码 文件名 &gt; 新文件名</p>
<p>查询目录大小<br> du -h –max-depth=1 . 2&gt; /dev/null</p>
<p>查看端口号被占用</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -tunlp|grep 8081</span><br></pre></td></tr></table></figure>

<h2 id="awk命令"><a href="#awk命令" class="headerlink" title="awk命令"></a>awk命令</h2><p>awk实现数字相加</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ll  *.avi | awk '&#123;sum+=$5&#125;;END &#123;print sum&#125;'</span><br></pre></td></tr></table></figure>
<p>mac 默认配置文件 是 ~/.zshrc</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/04/19/linux%E7%9F%A5%E8%AF%86/" data-id="ckgtnonn0000gm8ul910pe9w9" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-限流算法" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2020/04/13/%E9%99%90%E6%B5%81%E7%AE%97%E6%B3%95/" class="article-date">
  <time datetime="2020-04-12T16:19:59.867Z" itemprop="datePublished">2020-04-13</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/blog/2020/04/13/%E9%99%90%E6%B5%81%E7%AE%97%E6%B3%95/">限流算法</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="桶令牌算法"><a href="#桶令牌算法" class="headerlink" title="桶令牌算法"></a>桶令牌算法</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">RateLimter rateLimter = RateLimter.create(<span class="number">2</span>);</span><br><span class="line">rateLimter.acquire();<span class="comment">//每次获取一个，会阻塞</span></span><br><span class="line">rateLimter.tryAcquire();<span class="comment">//不会阻塞，超过流量后返回失败</span></span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yanglf007.gitee.io/blog/2020/04/13/%E9%99%90%E6%B5%81%E7%AE%97%E6%B3%95/" data-id="ckgtnonnb000um8ule2q8d52z" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    
    <a class="extend prev" rel="prev" href="/blog/page/3/">&amp;laquo; Prev</a><a class="page-number" href="/blog/">1</a><a class="page-number" href="/blog/page/2/">2</a><a class="page-number" href="/blog/page/3/">3</a><span class="page-number current">4</span>
  </nav>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/10/">October 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/08/">August 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/07/">July 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/06/">June 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/05/">May 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/04/">April 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/blog/2020/10/25/%E6%AF%8F%E6%97%A5%E5%AD%A6%E4%B9%A0/">每日学习</a>
          </li>
        
          <li>
            <a href="/blog/2020/10/12/mybatis-plus/">mybatis-plus</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/30/%E7%A7%92%E6%9D%80%E7%B3%BB%E7%BB%9F/">秒杀系统</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/29/elasticsearch%E7%9F%A5%E8%AF%86/">elasticsearch知识</a>
          </li>
        
          <li>
            <a href="/blog/2020/08/28/redis%E9%9D%A2%E8%AF%95/">redis面试</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 yanglf007<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/blog/" class="mobile-nav-link">Home</a>
  
    <a href="/blog/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/blog/fancybox/jquery.fancybox.css">

  
<script src="/blog/fancybox/jquery.fancybox.pack.js"></script>




<script src="/blog/js/script.js"></script>




  </div>
</body>
</html>